package com.byx.chatclient.view.activity.user;

import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.byx.chatclient.R;
import com.byx.chatclient.contract.user.RegisterTaskContract;
import com.byx.chatclient.presenter.user.RegisterPresenter;
import com.byx.chatclient.view.activity.BaseActivity;
import com.byx.chatclient.view.fragment.user.RegisterOneFragment;
import com.byx.chatclient.view.fragment.user.RegisterTwoFragment;
import com.gyf.immersionbar.ImmersionBar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import soup.neumorphism.NeumorphButton;

/**
 * 注册界面
 * @author Superb
 */
public class RegisterActivity extends AppCompatActivity {
    private static final String TAG = RegisterActivity.class.getSimpleName();

    @BindView(R.id.iv_back)
    protected ImageView mIvBack;
    private RegisterOneFragment mRegOneFragment;
    private RegisterTwoFragment mRegTwoFragment;

    private String email;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ImmersionBar.with(this).statusBarDarkFont(true).transparentStatusBar().fitsSystemWindows(true).init();
        setContentView(R.layout.activity_register);
        ButterKnife.bind(this);
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        mRegOneFragment = new RegisterOneFragment();
        mRegTwoFragment = new RegisterTwoFragment();
        //事务管理
        FragmentTransaction transaction = supportFragmentManager.beginTransaction();
        //默认显示第一个Frament
        transaction.add(R.id.fl_reg_form,mRegOneFragment).show(mRegOneFragment);
        //添加并隐藏
        transaction.add(R.id.fl_reg_form,mRegTwoFragment).hide(mRegTwoFragment);
        transaction.commit();

        mIvBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    //切换Fragment到注册页
    public void registerStepIn(){
        getSupportFragmentManager()
                .beginTransaction()
                .show(mRegTwoFragment).hide(mRegOneFragment).commit();

    }
    //切换到注册
    public void registerStepOut(){
        getSupportFragmentManager()
                .beginTransaction()
                .show(mRegOneFragment).hide(mRegTwoFragment).commit();
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
}